package com.damuzee.core.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil {
	/**
	 * email正则表达式
	 */
	public static final Pattern EMAIL_PATTERN = Pattern.compile("^\\w+(\\.\\w+)*@\\w+(\\.\\w+)+$");

	/**
	 * 验证是否为Email
	 * 
	 * @param email
	 * @return
	 */
	public static boolean isEmail(String email) {
		if (!StringUtil.isBlank(email)) {
			return false;
		}
		Matcher m = EMAIL_PATTERN.matcher(email);
		return m.matches();
	}

	/**
	 * 
	 * @param phoneNo
	 * @return
	 */
	public static boolean isPhoneNo(String phoneNo) {

		return true;
	}

	public static boolean isBlank(String str) {
		if (str != null && !str.equals("")) {
			return true;
		}
		return false;
	}

	public static boolean isLoginName(String loginName) {

		return (isBlank(loginName) || isPhoneNo(loginName) || isEmail(loginName));
	}

}
